package com.java.rabbitmq.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Woo_home
 * @create 2020/5/27 14:09
 */

@Configuration
public class FanoutConfig {

    // 声明交换机
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("FanoutExchange");
    }

    @Bean
    public Queue fanoutQueue() {
        return new Queue("FanoutQueue");
    }

    @Bean
    public Queue fanoutQueue2() {
        return new Queue("FanoutQueue2");
    }

    @Bean
    public Binding bindFanout() {
        return BindingBuilder
                .bind(fanoutQueue())
                .to(fanoutExchange());
    }

    @Bean
    public Binding bindFanout2() {
        return BindingBuilder
                .bind(fanoutQueue2())
                .to(fanoutExchange());
    }
}
